<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Audiobook Stand</title>
        <META HTTP-EQUIV="refresh" CONTENT="15"/> 
        <link href="resources/css/style.css" rel="stylesheet" type="text/css" />
        <h:outputScript library="js" name="//code.jquery.com/jquery-1.11.0.min.js"/>
        <h:outputScript library="primefaces" name="//code.jquery.com/jquery-migrate-1.2.1.min.js"/>
        <script src="resources/js/script.js"></script>
        <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"/>
        <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css"/>
        <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
    </h:head>
    <h:body class="loginbody">  
        <div class="logindiv">
            <p:tabView effect="fade" effectDuration="normal">
                <p:tab title="Giriş Yap">
                    <h:form id="loginForm">
                        <p:growl id="messagesForLogin" showDetail="true"/>
                        <h:panelGrid columns="2">
                            <h:outputText value="Kullanıcı adı:" />
                            <p:inputText id="username1" value="#{loginController.username}" required="true" requiredMessage="Lütfen kullanıcı adı giriniz"/>
                            <h:outputText value="Şifre:"/>
                            <p:password id="password1" value="#{loginController.password}" required="true" 
                                        requiredMessage="Lütfen şifre giriniz" />
                            <br/>
                            <h:commandButton type="submit" value="Giriş Yap" action="#{loginController.login()}"/>
                        </h:panelGrid>
                    </h:form>
                </p:tab>
                <p:tab title="Kayıt Ol">
                    <h:form id="registerForm">
                        <p:growl id="messagesForLogin" showDetail="true"/>
                        <h:panelGrid columns="2">
                            <p:outputLabel value="Kullanıcı Adı:"  />
                            <p:inputText id="username" value="#{customerController.selected.username}" required="true" requiredMessage="Lütfen bir kullanıcı adı giriniz"/>
                            <p:outputLabel  value="İsim:"/>
                            <p:inputText id="name" value="#{customerController.selected.name}" required="true" requiredMessage="Lütfen bir isim giriniz"/>
                            <p:outputLabel value="Soyisim:"  />
                            <p:inputText id="surname" value="#{customerController.selected.surname}" required="true" requiredMessage="Lütfen bir soyisim giriniz"/>
                            <p:outputLabel value="Adres:" for="address" />
                            <p:inputTextarea id="address" value="#{customerController.selected.address}" required="true" requiredMessage="Lütfen adres giriniz"/>
                            <p:outputLabel value="Şifre:" for="password" />
                            <p:password id="password" feedback="true"
                                promptLabel="Lütfen şifre giriniz" weakLabel="Zayıf"
                                goodLabel="Orta seviye" strongLabel="Güçlü" value="#{customerController.selected.password}"/>
                            <p:outputLabel value="Email:" for="email" />
                            <p:inputText id="email" value="#{customerController.selected.email}" required="true" requiredMessage="Lütfen bir mail adresi giriniz"
                                         validatorMessage="Lütfen geçerli bir mail adresi giriniz">
                                <f:validateRegex
                                        pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
                            </p:inputText>
                            <p:outputLabel value="İl:"  />
                            <p:selectOneMenu value="#{customerController.selected.cityid}"  effect="fade" id="cityid">
                                <f:selectItem itemLabel="-- İl seçiniz -- " itemValue="0"/> 
                                <f:selectItems value="#{customerController.citys}" var="city" itemLabel="#{city.cityname}" />  
                                <f:ajax event="change" rendered="countyid"/>
                            </p:selectOneMenu> 
                            <p:outputLabel value="İlçe:"/>
                            <p:selectOneMenu value="#{customerController.selected.countyid}" effect="fade" id="countyid">  
                                <f:selectItem itemLabel="-- İlçe seçiniz -- " itemValue="0"/> 
                                <f:selectItems value="#{customerController.countys}" var="county" itemLabel="#{county.countyname}" />  
                            </p:selectOneMenu> 
                            <br/>
                            <br/>
                            <h:commandButton type="submit" value="Kayıt Ol" id="registerCustomer" action="#{customerController.goToMainpage()}" actionListener="#{customerController.registerUser()}"/>
                        </h:panelGrid>
                    </h:form>
                </p:tab>
            </p:tabView>
        </div>
    </h:body>
</html>
